<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue</title>
    <script type="text/javascript" src="../../js/vue.js"></script>

</head>
<body>
    <div id="root">
        <button @click.once="add">点击添加一个人员</button>
         <!-- 遍历数组 -->
         <ul>
            <li v-for= "(p,index) in persons" :key="p.id">
                {{p.name}} - {{p.age}} - {{index}} 
                <input type="text">
            </li>
        </ul>
        <hr>
    </div>

    <script type="text/javascript">
        Vue.config.performance = false;
        const vm = new Vue({
            el:'#root',
            data() {
                return {
                    persons:[
                        {id:'001',name:"zw",age:12},
                        {id:'002',name:"ls",age:18},
                        {id:'003',name:"sd",age:20}
                    ]
                };
            },
            methods: {
                add(){
                    const p = {id:'004',name:'lx',age:30}
                    // 头部添加
                    this.person.unshift(p)
                    // 往后追加
                    //this.person.push(p)
                }
            },
        })

    </script>

</body>
</html>